#define  _CRT_SECURE_NO_WARNINGS 1

int maxSubArray(int* nums, int numsSize) {
    int prev = 0;
    int max = nums[0];
    for (int i = 0; i < numsSize; i++)
    {
        prev = fmax(prev + nums[i], nums[i]);
        max = fmax(prev, max);
    }

    return max;
}